package com.hssy.wululuaplan.controller;


import com.hssy.wululuaplan.common.Result;
import com.hssy.wululuaplan.entity.Student;
import com.hssy.wululuaplan.form.DivideClassForm;
import com.hssy.wululuaplan.service.DivideClassService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 班级划分 前端控制器
 * </p>
 *
 * @author Mr.Hongtao
 * @since 2024-02-28
 */
@Api(tags = "班级划分")
@RestController
@RequestMapping("/wululuaplan/divide-class")
public class DivideClassController {

    @Resource
    private DivideClassService divideClassService;

    @ApiOperation(value = "查询指定班级的全部学生")
    @GetMapping("/findStudentListByCourseId")
    public Result<List<Student>> findStudentListByCourseId(@RequestParam(value = "courseId")Integer courseId) {
        List<Student> list = divideClassService.findStudentListByCourseId(courseId);
        return Result.success(list);
    }

    @ApiOperation(value = "筛选出全部可选学生",notes = "只有缴过费的才能分班，不管是否还有剩余课时。如果剩余课时为0的，只是无法签到，排课都可以排，只要缴费了可以重新补签")
    @GetMapping("/filterSelectableStudents")
    public Result<List<Student>> filterSelectableStudents() {
        List<Student> list = divideClassService.filterSelectableStudents();
        return Result.success(list);
    }

    @ApiOperation(value = "调整班级学生", notes = "增删改都是这个接口")
    @PostMapping("adjustClassStudents")
    public Result<?> adjustClassStudents(@RequestBody DivideClassForm form) {
        divideClassService.adjustClassStudents(form);
        return Result.success();
    }
}

